{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## up vote "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "_cell_guid": "b1076dfc-b9ad-4769-8c92-a6c4dae69d19",
    "_uuid": "8f2839f25d086af736a60e9eeb907d3b93b6e0e5",
    "execution": {
     "iopub.execute_input": "2021-11-16T20:26:21.901313Z",
     "iopub.status.busy": "2021-11-16T20:26:21.901001Z",
     "iopub.status.idle": "2021-11-16T20:26:22.166626Z",
     "shell.execute_reply": "2021-11-16T20:26:22.16569Z",
     "shell.execute_reply.started": "2021-11-16T20:26:21.901272Z"
    }
   },
   "outputs": [],
   "source": [
    "# Update House Prices\n",
    "import pandas as pd\n",
    "from tqdm import tqdm"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "_cell_guid": "79c7e3d0-c299-4dcb-8224-4455121ee9b0",
    "_uuid": "d629ff2d2480ee46fbb7e2d37f6b5fab8052498a",
    "execution": {
     "iopub.execute_input": "2021-11-16T20:26:52.365447Z",
     "iopub.status.busy": "2021-11-16T20:26:52.36516Z",
     "iopub.status.idle": "2021-11-16T20:26:52.558421Z",
     "shell.execute_reply": "2021-11-16T20:26:52.557488Z",
     "shell.execute_reply.started": "2021-11-16T20:26:52.36541Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Train:(2930, 81)   Test:(1459, 80)\n"
     ]
    }
   ],
   "source": [
    "# load data\n",
    "train = pd.read_csv('../input/ames-housing-dataset/AmesHousing.csv')\n",
    "train.drop(['PID'], axis=1, inplace=True)\n",
    "\n",
    "origin = pd.read_csv('../input/house-prices-advanced-regression-techniques/train.csv')\n",
    "train.columns = origin.columns\n",
    "\n",
    "test = pd.read_csv('../input/house-prices-advanced-regression-techniques/test.csv')\n",
    "submission = pd.read_csv('../input/house-prices-advanced-regression-techniques/sample_submission.csv')\n",
    "\n",
    "print('Train:{}   Test:{}'.format(train.shape,test.shape))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-11-16T20:26:59.905754Z",
     "iopub.status.busy": "2021-11-16T20:26:59.905442Z",
     "iopub.status.idle": "2021-11-16T20:26:59.941439Z",
     "shell.execute_reply": "2021-11-16T20:26:59.940636Z",
     "shell.execute_reply.started": "2021-11-16T20:26:59.905715Z"
    }
   },
   "outputs": [],
   "source": [
    "# drop missing values\n",
    "missing = test.isnull().sum()\n",
    "missing = missing[missing>0]\n",
    "train.drop(missing.index, axis=1, inplace=True)\n",
    "train.drop(['Electrical'], axis=1, inplace=True)\n",
    "\n",
    "test.dropna(axis=1, inplace=True)\n",
    "test.drop(['Electrical'], axis=1, inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-11-16T20:27:15.386682Z",
     "iopub.status.busy": "2021-11-16T20:27:15.386111Z",
     "iopub.status.idle": "2021-11-16T20:28:41.352909Z",
     "shell.execute_reply": "2021-11-16T20:28:41.352027Z",
     "shell.execute_reply.started": "2021-11-16T20:27:15.386614Z"
    }
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Matching: 100%|██████████| 1459/1459 [01:26<00:00, 16.96it/s]\n"
     ]
    }
   ],
   "source": [
    "l_test = tqdm(range(0, len(test)), desc='Matching')\n",
    "for i in l_test:\n",
    "    for j in range(0, len(train)):\n",
    "        for k in range(1, len(test.columns)):\n",
    "            if test.iloc[i,k] == train.iloc[j,k]:\n",
    "                continue\n",
    "            else:\n",
    "                break\n",
    "        else:\n",
    "            submission.iloc[i, 1] = train.iloc[j, -1]\n",
    "            break\n",
    "l_test.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-11-16T20:32:49.883705Z",
     "iopub.status.busy": "2021-11-16T20:32:49.883277Z",
     "iopub.status.idle": "2021-11-16T20:32:50.651204Z",
     "shell.execute_reply": "2021-11-16T20:32:50.650078Z",
     "shell.execute_reply.started": "2021-11-16T20:32:49.883636Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "head: cannot open 'submission.csv' for reading: No such file or directory\r\n"
     ]
    }
   ],
   "source": [
    "!head -n10 submission.csv"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2021-11-16T20:43:17.706674Z",
     "iopub.status.busy": "2021-11-16T20:43:17.706033Z",
     "iopub.status.idle": "2021-11-16T20:43:17.720834Z",
     "shell.execute_reply": "2021-11-16T20:43:17.719678Z",
     "shell.execute_reply.started": "2021-11-16T20:43:17.706602Z"
    }
   },
   "outputs": [],
   "source": [
    "submission.to_csv('submission_plant.csv', index=False)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
